package com.slz3.business.module.configManagement.conFeedback.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.slz3.business.frame.enums.AuditFlag;
import com.slz3.business.frame.enums.UsingFlag;
import com.slz3.business.frame.functions.Add;
import com.slz3.business.frame.functions.Modify;
import com.slz3.business.frame.module.DomainEntity;
import com.slz3.business.module.configManagement.conVersion.domain.OperatingSystemEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Type;
import org.hibernate.validator.constraints.Length;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.time.LocalDate;

import static javax.persistence.EnumType.STRING;

@MappedSuperclass
@Data
@EqualsAndHashCode(callSuper = false)
public class ConFeedbackEntity extends DomainEntity {

    /**
     * 编号
     */
    @Column(length = 80)
    @NotNull(message = "serNum 必须非空!", groups = {Add.class, Modify.class})
    @Length(min = 1, max = 80, message = "ser2 必须非空并且不超过 80 个字符!", groups = {Add.class, Modify.class})
    private String serNum;

    /**
     * 备注
     */
    @Basic(fetch = FetchType.LAZY)
    @Type(type = "text")
    private String serMemo;


    /**
     * 标题
     */
    private String title;


    /**
     * 反馈内容。
     */
    @Column(columnDefinition = "TEXT")
    private String content = "";
    /**
     * 联系方式。
     */
    private String contactInfo = "";

    /**
     * 处理结果。
     */
    @Column(columnDefinition = "TEXT")
    private String handleResult = "";

    /**
     * 反馈图片URL， 逗号分隔
     */
    private String imgUrls = "";
    /**
     * 反馈用户ID
     */
    private String userID = "";

    /**
     * 反馈用户名
     */
    private String userName = "";

    /**
     * 审核状态
     */
    @Enumerated(STRING)
    @Null(message = "serAudit 必须为空!", groups = {Modify.class})
    private AuditFlag serAudit;

    /**
     * 启用状态
     */
    @Enumerated(STRING)
    @Null(message = "serUsing 必须为空!", groups = {Modify.class})
    private UsingFlag serUsing;


    /**
     * 标签
     */
    private String serLabels;

    /**
     * 文件 url 地址
     */
    private String serFileUrl;

    /**
     * APP版本号
     */
    @NotNull(message = "APP版本号 必须非空!", groups = {Add.class, Modify.class})
    @Length(min = 1, max = 200, message = "必须非空并且不超过 200 个字符!", groups = {Add.class, Modify.class})
    private String serVersionNumber;

    /**
     * 操作系统
     */
    @Enumerated(STRING)
    @Null(message = "操作系统 必须非空!", groups = {Modify.class})
    private OperatingSystemEnum serOperatingSystem;



    /**
     * 富文本编辑器内容
     */
    @Basic(fetch = FetchType.LAZY)
    @Column(columnDefinition = "TEXT")
    private String serEditorContent;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    private LocalDate serInputGroupData;

}
